/*
*
* @desc
* */
const {ddl2json} = require("../common/ddl2json");

const {initEnv} = require("../common/parseEnv");
const {
    connect,
    add,
    update,
    getOne,
    getList,
    getCount,
} = require('../common/db.js')

const path = require('path')
initEnv(path.resolve(__dirname, '.env'))

var params = {
    host: process.env.host,
    user: process.env.user,
    password: process.env.password,
    database: process.env.database,
}
console.log("params", params)
connect(params)

function 获取ddl2json() {
    var a = ddl2json('CREATE TABLE `act_evt_log` (\n' +
        '  `LOG_NR_` bigint(20) NOT NULL AUTO_INCREMENT,\n' +
        '  `TYPE_` varchar(64) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `PROC_DEF_ID_` varchar(64) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `PROC_INST_ID_` varchar(64) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `EXECUTION_ID_` varchar(64) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `TASK_ID_` varchar(64) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `TIME_STAMP_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),\n' +
        '  `USER_ID_` varchar(255) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `DATA_` longblob,\n' +
        '  `LOCK_OWNER_` varchar(255) COLLATE utf8_bin DEFAULT NULL,\n' +
        '  `LOCK_TIME_` timestamp(3) NULL DEFAULT NULL,\n' +
        '  `IS_PROCESSED_` tinyint(4) DEFAULT \'0\',\n' +
        '  PRIMARY KEY (`LOG_NR_`) USING BTREE\n' +
        ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;')
    /*  { LOG_NR_: '',
          TYPE_: '',
          PROC_DEF_ID_: '',
          PROC_INST_ID_: '',
          EXECUTION_ID_: '',
          TASK_ID_: '',
          TIME_STAMP_: '',
          USER_ID_: '',
          DATA_: '',
          LOCK_OWNER_: '',
          LOCK_TIME_: '',
          IS_PROCESSED_: '' }*/

    console.log(a)
}



async function 修改项目() {
    var result=await add("act_evt_log", {
            LOG_NR_: '6',
            TYPE_: '1',
            PROC_DEF_ID_: '1',
            PROC_INST_ID_: '1',
            EXECUTION_ID_: '1',
            TASK_ID_: '1',
            TIME_STAMP_: new Date(),
            USER_ID_: '1',
            DATA_: '1',
            LOCK_OWNER_: '1',
            LOCK_TIME_: new Date(),
            IS_PROCESSED_: '1'
        },{LOG_NR_: '4'}
    )
    console.log(result)
}

// 获取ddl2json()
修改项目()